<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [formGroup]="formGroup" class="formGroup aui-gutter-column-xxl">
  <lv-form-item>
    <lv-form-label lvRequired>
      {{ 'common_name_label' | i18n }}
    </lv-form-label>
    <lv-form-control [lvErrorTip]="nameErrorTip">
      <input
        lv-input
        type="text"
        formControlName="name"
        [placeholder]="
          i18n.get('protection_instance_name_placeholder_label')
        "
      />
    </lv-form-control>
  </lv-form-item>
  <lv-form-item>
    <lv-form-label lvRequired>
      {{ 'protection_instance_id_label' | i18n }}
    </lv-form-label>
    <lv-form-control [lvErrorTip]="instanceIdErrorTip">
      <input
        lv-input
        type="text"
        formControlName="instanceId"
        [placeholder]="
          i18n.get('protection_instance_id_placeholder_label')
        "
      />
    </lv-form-control>
  </lv-form-item>
  <lv-form-item>
    <lv-form-label lvRequired>
      {{ 'common_host_label' | i18n }}
    </lv-form-label>
    <lv-form-control [lvErrorTip]="baseUtilService.requiredErrorTip">
      <lv-select
        [lvOptions]="hostOptions"
        formControlName="host"
        lvValueKey="value"
        lvMode="multiple"
        lvShowFilter
        lvShowCheckAll
        lvFilterKey="label"
        lvFilterMode="contains"
      >
      </lv-select>
    </lv-form-control>
  </lv-form-item>
  <lv-form-item>
    <lv-form-label lvRequired>
      {{ 'protection_auth_mode_label' | i18n }}
    </lv-form-label>
    <lv-form-control>
      <lv-select
        formControlName="authMode"
        [lvOptions]="authOptions"
        lvValueKey="value"
      >
      </lv-select>
    </lv-form-control>
  </lv-form-item>
  <lv-form-item
    *ngIf="formGroup.value.authMode === dataMap.saphanaAuthMethod.db.value"
  >
    <lv-form-label lvRequired>
      {{ 'protection_system_database_user_name_label' | i18n }}
    </lv-form-label>
    <lv-form-control [lvErrorTip]="usernameErrorTip">
      <input
        lv-input
        type="text"
        formControlName="userName"
        autocomplete="new-password"
        [placeholder]="this.i18n.get('protection_system_database_user_name_placeholder_label')"
      />
    </lv-form-control>
  </lv-form-item>
  <lv-form-item
    *ngIf="formGroup.value.authMode === dataMap.saphanaAuthMethod.db.value"
  >
    <lv-form-label lvRequired>
      {{ 'protection_system_database_password_label' | i18n }}
    </lv-form-label>
    <lv-form-control [lvErrorTip]="passwordErrorTip">
      <aui-inupt-with-eye
        formControlName="password"
        [placeholder]="
          i18n.get('protection_system_database_password_placeholder_label')
        "
      ></aui-inupt-with-eye>
    </lv-form-control>
  </lv-form-item>
  <lv-form-item
    *ngIf="formGroup.value.authMode === dataMap.saphanaAuthMethod.db.value"
  >
    <lv-form-label lvRequired>
      {{ 'protection_system_database_port_label' | i18n }}
    </lv-form-label>
    <lv-form-control [lvErrorTip]="portErrorTip">
      <input
        lv-input
        type="text"
        formControlName="port"
        [placeholder]="
          i18n.get('protection_system_database_port_placeholder_label')
        "
      />
    </lv-form-control>
  </lv-form-item>
  <lv-form-item
    *ngIf="
      formGroup.value.authMode === dataMap.saphanaAuthMethod.hdbuserstore.value
    "
  >
    <lv-form-label lvRequired>
      {{ 'Hdbuserstore KEY' | i18n }}
    </lv-form-label>
    <lv-form-control [lvErrorTip]="instanceIdErrorTip">
      <aui-inupt-with-eye
        formControlName="hdbuserstoreKey"
        [placeholder]="
          i18n.get('common_please_enter_label', [i18n.get('Hdbuserstore KEY')])
        "
      ></aui-inupt-with-eye>
    </lv-form-control>
  </lv-form-item>
  <lv-form-item>
    <lv-form-label>
      {{ 'common_log_backup_label' | i18n }}
        <i lv-icon="aui-icon-help" lv-tooltip="{{'protection_saphana_log_backup_tips_label' | i18n}}" lvTooltipTheme="light"
           class="configform-constraint" lvColorState='true'></i>
    </lv-form-label>
    <lv-form-control>
      <lv-switch formControlName="logBackup"></lv-switch>
      <ng-container *ngIf="!!formGroup.value.logBackup">
          <div>
              <i lv-icon="lv-icon-status-info"></i>
              <span class="text-middle" style="margin-left:8px">{{'protection_informix_register_log_tip_label' | i18n}}</span>
          </div>
        <div class="aui-gutter-column-md"></div>
        <lv-form-item>
          <lv-form-label [lvKeepRequiredWidth]="false">
            {{ 'portection_logbackup_time_interval_label' | i18n }}
          </lv-form-label>
            <lv-form-control [lvErrorTip]="portErrorTip">
          <lv-group lvGutter="8px" [lvColumns]="['auto', '120px']">
              <input lv-input type="text" formControlName="logBackupInterval" />
              <lv-select
                formControlName="logBackupUnit"
                [lvOptions]="unitOptions"
                lvValueKey="value"
              >
              </lv-select>
          </lv-group>
            </lv-form-control>
        </lv-form-item>
        <lv-form-item>
          <lv-form-label [lvKeepRequiredWidth]="false">
            {{ 'protection_logbackup_file_path_label' | i18n }}
          </lv-form-label>
          <lv-form-control [lvErrorTip]="instanceIdErrorTip">
            <input
              lv-input
              type="text"
              formControlName="logBackupPath"
              placeholder="{{
                'protection_logbackup_file_path_tips_label' | i18n
              }}"
            />
          </lv-form-control>
        </lv-form-item>
      </ng-container>
    </lv-form-control>
  </lv-form-item>
</lv-form>
